package com.cssl.config;
import org.springframework.stereotype.Component;

import java.io.FileWriter;
import java.io.IOException;

/* *
 *类名：AlipayConfig
 *功能：基础配置类
 *详细：设置帐户有关信息及返回路径
 *修改日期：2017-04-05
 *说明：
 *以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
 *该代码仅供学习和研究支付宝接口使用，只是提供一个参考。
 */

@Component
public class AlipayConfig {

    //↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
    public static String app_id = "9021000126665169";

    // 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCWq+1BUNKorL0q0ial9epdk96QGPD5mEDDCEAUZr+i4mH1i9fcN9qPo8pmQJDeRZ0BzwvWcLejSzE4ZTX/weluiXcPs8B00i/okBobAIY6uwCI4PyMBg5jYAgAyKqdpRPOKvjQAJOQVhOxu5BoT7Neisr7Viqm2WUPQowROB2U9qE8VEejTTGias+fghEZv/DQnlYKwLteG0g2I/SsQBJc9dumF5nqGqFOx0/6YSMAjhtemgk1GgQFX2TEaIrTmRCyU5dTRC5VHmshY+68G5msKZ1amgCiCUr/otIBhSxshM8TTPHydV+tqJfbtddyqE4wKdmnbWSRM44qSBHzVpjFAgMBAAECggEAEnKKYezbXfuITa3dPYSWZU6teUcUefrCMx7Xeaf63p6JD99HVpcgE2YiadKN6ijryETpViAG299g71609dNwGTCLe0iuz57MbtT13Uh7JsWukxO42AwFxvUDBdWLzjFf82YfgJgReSKQ1rn4PE1F0NV9dLhgEH2defjT3WfZd1tqafEWwlSjx3mDwXqGX55VaNHydqmYk3bxJAXDTeC8uehHrFXOoOoACWD33K6exhVaFvQayGWHfOEmsfZlKb9yka0TgrabuDbrK6rc9drpPn4v7ZHih6aJJ5SFn5OUV0H4Xb5g4X0635068h8ezN9PoCHZ8yWIFJVldTTvfQQsAQKBgQDg1NtZk/z1Dvv+5rfVaJnaHFuQCPFq6l2pQMkeQFHpoP+EgSskanWUmdo4mXazHgFKeGSYRiz/SjRRdy/yGDLrsYIbpVNojfNpXsO7FoTwFZi2JKpKMJu6Ze1/aUruiMAW7lXIo9uzNxem/v7Sqm7tCLGtmKzsotEQcki1gaaFJQKBgQCrjy1bs5Nsbb6ZwD8inFMa0JzEM3N0R1hmtljRM2UD5WfehsJAMgiPiL0RU/J+idolf+rbekYZVAiBNVJnNkZblmWb2H8+SUDZWcmHmJNfhoEhB20HjwBMg1Jhhc/wdpUAo9tie9ZHvwyl2A4GL6d/SiJY0cRzA6ZReuuO6xADIQKBgD9A421ySyqOyqrOMk4iHZbVf5UoTvNreGpTxcFzCxiVqQ2YYZDfOrFSD6j41AJUoLxY3sRQifxQ3iNFSwHrePgCer5YZvz1YtP0S1DpZwE8sjgcXKR+xHFOl+DOuLwfURuidhP6tabYCxl6iCqwtICPf519ZLk2nWbpIDeggD7ZAoGBAIrTCTkzTxBmnd18m5o+NWF1feWmXL6zHO3AkI54sD0+3ZZMJdQcqKC9XYEwFQIgOs4tfLatcxv7zAYCR/QND1H9matKvWyBimBXL6Tx6g9aoBNCFxAOv4cqnPcdeO50ho5GCbjfzL2x82IgOvj2huuR6clFtVn8khFNDmBQBl0BAoGAZdThry2ps5GYuF0znpBskWvn3rIfE9WyLYKsuMCpeUZBZy8ued5I45o8Nioqd5OgjdLgnHxu93H74iDguepZPsnEDhCajbLmXAjMkEuv4cSEaFw6BrXDykXt1ZOu3Wz9wtSB9tCJlqgGBhbAZdqCzQmI21L9zXKd2hLoTEAMhhE=";
    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlqvtQVDSqKy9KtImpfXqXZPekBjw+ZhAwwhAFGa/ouJh9YvX3Dfaj6PKZkCQ3kWdAc8L1nC3o0sxOGU1/8Hpbol3D7PAdNIv6JAaGwCGOrsAiOD8jAYOY2AIAMiqnaUTzir40ACTkFYTsbuQaE+zXorK+1YqptllD0KMETgdlPahPFRHo00xomrPn4IRGb/w0J5WCsC7XhtINiP0rEASXPXbpheZ6hqhTsdP+mEjAI4bXpoJNRoEBV9kxGiK05kQslOXU0QuVR5rIWPuvBuZrCmdWpoAoglK/6LSAYUsbITPE0zx8nVfraiX27XXcqhOMCnZp21kkTOOKkgR81aYxQIDAQAB";

    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问，假设这里的公网IP和端口为：49.269.31.237:8081
    public static String notify_url = "http://localhost/pet/page/farmed.html";

    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问，假设这里的公网IP和端口为：49.269.31.237:8081
    public static String return_url = "http://localhost/pet/page/farmed.html";

    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String charset = "utf-8";

    // 支付宝网关
    public static String gatewayUrl = "https://openapi-sandbox.dl.alipaydev.com/gateway.do";

    // 支付宝网关
    public static String log_path = "C:\\";



    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

